<?php
class Post_trip_model extends CI_Model {


	function post_trip($from,$to,$max,$year,$month,$day,$time,$driver,$user){
		$this->load->database();
		$latest = $this->db->query("select max(tid) as latest from tripinfo");
		$tid = $latest->row(0)->latest + 1;
		$depart_time = "$year" . "-" .  "$month" . "-" . "$day" ."\t" . "$time" . ":" . "00";
		$query1 = "insert into tripinfo values(?,?,?,?,?,?)";
		$query2 = "insert into tripmembers values(?,?)";
		$this->db->query($query1,array($tid,$to,$from,$depart_time,$max,$driver));
		$this->db->query($query2,array($tid,$user));
		if($driver){
			$query1 = "insert into drivers values(?,?)";
			$this->db->query($query1,array($tid,$user));
		}
		return $tid;
	}
}
?>